<HTML><HEAD><TITLE>indomain(?Var, ++Method)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(fd_search)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>indomain(?Var, ++Method)</H1>
a flexible way to assign values to finite domain variables
<DL>
<DT><EM>Var</EM></DT>
<DD>a domain variable or an integer
</DD>
<DT><EM>Method</EM></DT>
<DD>one of the atoms min, max, middle, median, split, interval, random or an integer
</DD>
</DL>
<H2>Description</H2>
This predicate provides a flexible way to assign values to finite 
domain variables.<p>
The available methods are:
<ul>
<li><b>min</b> Start the enumeration from the smallest value upwards. 
    This behaves like the built-in <b>indomain/1</b>, except that it
    removes previously tested values on backtracking.</li>

<li><b>max</b> Start the enumeration from the largest value
    downwards.</li>

<li><b>middle</b> Try the enumeration starting from the middle of the
    domain.  On backtracking, this chooses alternatively values above and
    below the middle value, until all alternatives have been tested.</li>

<li><b>median</b> Try the enumeration starting from the median value
    of the domain.  On backtracking, this chooses alternatively values
    above and below the median value, until all alternatives have been
    tested.</li>

<li><b>split</b> Try the enumeration by splitting the domain
    successively into halves until a ground value is reached.  This
    sometimes can detect failure earlier than the normal enumeration
    methods, but enumerates the values in the same order as min.</li>

<li><b>interval</b> If the domain consists of several intervals, then
    we branch first on the choice of the interval.  For one interval, we
    use domain splitting.</li>

<li><b>random</b> Try the enumeration in a random order.  On
    backtracking, the previously tested value is removed.  This method
    uses <b>random/1</b> to create random numbers, use <b>seed/1</b>
    before to make results reproducible.</li>

<li><b>Value:integer</b> Like middle, but start with the given integer
    <b>Value</b></li>

<li><b>sbds_min</b> Like min, but use <b>sbds_try/2</b> to make choices (for
    use in conjunction with the SBDS symmetry breaking library).</li>

<li><b>sbds_max</b> Like max, but use <b>sbds_try/2</b> to make choices (for
    use in conjunction with the SBDS symmetry breaking library).</li>

<li><b>sbds_middle</b> Like middle, but use <b>sbds_try/2</b> to make choices
    (for use in conjunction with the SBDS symmetry breaking library).</li>

<li><b>sbds_median</b> Like median, but use <b>sbds_try/2</b> to make choices
    (for use in conjunction with the SBDS symmetry breaking library).</li>

<li><b>sbds_random</b> Like random, but use <b>sbds_try/2</b> to make choices
    (for use in conjunction with the SBDS symmetry breaking library).</li>

<li><b>sbds(Value:integer)</b> Like Value:integer, but use <b>sbds_try/2</b>
    to make choices (for use in conjunction with the SBDS symmetry breaking
    library).</li>

<li><b>gap_sbds_min</b> Like min, but use <b>sbds_try/2</b> to make choices (for
    use in conjunction with the GAP-based SBDS symmetry breaking library,
    lib(ic_gap_sbds)).</li>

<li><b>gap_sbds_max</b> Like max, but use <b>sbds_try/2</b> to make choices (for
    use in conjunction with the GAP-based SBDS symmetry breaking library,
    lib(ic_gap_sbds)).</li>

<li><b>gap_sbds_middle</b> Like middle, but use <b>sbds_try/2</b> to make choices
    (for use in conjunction with the GAP-based SBDS symmetry breaking
    library, lib(ic_gap_sbds)).</li>

<li><b>gap_sbds_median</b> Like median, but use <b>sbds_try/2</b> to make choices
    (for use in conjunction with the GAP-based SBDS symmetry breaking
    library, lib(ic_gap_sbds)).</li>

<li><b>gap_sbds_random</b> Like random, but use <b>sbds_try/2</b> to make choices
    (for use in conjunction with the GAP-based SBDS symmetry breaking
    library, lib(ic_gap_sbds)).</li>

<li><b>gap_sbds(Value:integer)</b> Like Value:integer, but use <b>sbds_try/2</b>
    to make choices (for use in conjunction with the GAP-based SBDS symmetry
    breaking library, lib(ic_gap_sbds)).</li>

<li><b>gap_sbdd_min</b> Like min, but use <b>sbdd_try/2</b> to make choices (for
    use in conjunction with the GAP-based SBDD symmetry breaking library,
    lib(ic_gap_sbdd)).</li>

<li><b>gap_sbdd_max</b> Like max, but use <b>sbdd_try/2</b> to make choices (for
    use in conjunction with the GAP-based SBDD symmetry breaking library,
    lib(ic_gap_sbdd)).</li>

<li><b>gap_sbdd_middle</b> Like middle, but use <b>sbdd_try/2</b> to make choices
    (for use in conjunction with the GAP-based SBDD symmetry breaking
    library, lib(ic_gap_sbdd)).</li>

<li><b>gap_sbdd_median</b> Like median, but use <b>sbdd_try/2</b> to make choices
    (for use in conjunction with the GAP-based SBDD symmetry breaking
    library, lib(ic_gap_sbdd)).</li>

<li><b>gap_sbdd_random</b> Like random, but use <b>sbdd_try/2</b> to make choices
    (for use in conjunction with the GAP-based SBDD symmetry breaking
    library, lib(ic_gap_sbdd)).</li>

<li><b>gap_sbdd(Value:integer)</b> Like Value:integer, but use <b>sbdd_try/2</b>
    to make choices (for use in conjunction with the GAP-based SBDD symmetry
    breaking library, lib(ic_gap_sbdd)).</li>
</ul>
On backtracking, all methods first remove the previously tested value
before choosing a new one.  This sometimes can have a huge impact on
the constraint propagation, and normally does not cause much overhead,
even if no additional propagation occurs.

<H3>Fail Conditions</H3>
No
<H3>Resatisfiable</H3>
yes
<H2>Examples</H2>
<PRE>
top:-
	X :: 1..10,
	indomain(X,min),
	write(X),put(32),
	fail.
top.

% writes 1 2 3 4 5 6 7 8 9 10

top:-
	X :: 1..10,
	indomain(X,max),
	write(X),put(32),
	fail.
top.

% writes 10 9 8 7 6 5 4 3 2 1

top:-
	X :: 1..10,
	indomain(X,middle),
	write(X),put(32),
	fail.
top.

% writes 5 6 4 7 3 8 2 9 1 10

top:-
	X :: 1..10,
	indomain(X,median),
	write(X),put(32),
	fail.
top.

% writes 5 6 4 7 3 8 2 9 1 10

top:-
	X :: 1..10,
	indomain(X,3),
	write(X),put(32),
	fail.
top.

% writes 3 4 2 5 1 6 7 8 9 10

top:-
	X :: 1..10,
	indomain(X,split),
	write(X),put(32),
	fail.
top.

% writes 1 2 3 4 5 6 7 8 9 10

top:-
	X :: 1..10,
	indomain(X,random),
	write(X),put(32),
	fail.
top.

% writes for example 5 3 7 6 8 1 2 10 9 4

</PRE>
<H2>See Also</H2>
<A HREF="../../lib/fd_search/search-6.html">search / 6</A>, <A HREF="../../lib/ic_symbolic/indomain-1.html">ic_symbolic : indomain / 1</A>, <A HREF="../../lib/sd/indomain-1.html">sd : indomain / 1</A>, <A HREF="../../lib/fd/indomain-1.html">fd : indomain / 1</A>, <A HREF="../../lib/ic/indomain-1.html">ic : indomain / 1</A>, <A HREF="../../kernel/arithmetic/random-1.html">random / 1</A>, <A HREF="../../kernel/arithmetic/seed-1.html">seed / 1</A>, <A HREF="../../lib/ic_gap_sbds/sbds_try-2.html">ic_gap_sbds : sbds_try / 2</A>, <A HREF="../../lib/ic_sbds/sbds_try-2.html">ic_sbds : sbds_try / 2</A>, <A HREF="../../lib/fd_sbds/sbds_try-2.html">fd_sbds : sbds_try / 2</A>, <A HREF="../../lib/ic_gap_sbdd/sbdd_try-2.html">ic_gap_sbdd : sbdd_try / 2</A>
</BODY></HTML>
